package com.sdcqjy.property.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sdcqjy.mylibrary.adapter.SuperRecyclerAdapter;
import com.sdcqjy.property.R;
import com.sdcqjy.property.mode.LawRegulationsDetailsMode;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by 磁磁帅 on 2018/7/8.
 * 功能：
 */
public class BookMarkAdapter extends SuperRecyclerAdapter<LawRegulationsDetailsMode> {
    public BookMarkAdapter(Context context, List<LawRegulationsDetailsMode> modeList) {
        super(context, modeList);
    }

    public int getLayoutId() {
        return R.layout.item_book_mark_list;
    }

    public SuperRecyclerAdapter.ViewHolder<LawRegulationsDetailsMode> getViewHolder(View view) {
        return new ViewHolder(view);
    }

    private OnAdapterClickListener onAdapterClickListener;

    public BookMarkAdapter setOnAdapterClickListener(OnAdapterClickListener onAdapterClickListener) {
        this.onAdapterClickListener = onAdapterClickListener;
        return this;
    }

    public class ViewHolder extends SuperRecyclerAdapter.ViewHolder<LawRegulationsDetailsMode> implements View.OnClickListener {
        @BindView(R.id.textTitle)
        TextView textTitle;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
            view.setOnClickListener(this);
        }

        @OnClick(R.id.imgArr)
        public void onViewClicked() {
            if (onAdapterClickListener != null) onAdapterClickListener.deleBookMark(mode);
        }

        public void setData(LawRegulationsDetailsMode mode) {
            super.setData(mode);
            textTitle.setText(mode.title);
        }

        public void onClick(View v) {
            if (onAdapterClickListener != null) onAdapterClickListener.toBookMark(mode);
        }
    }

    public interface OnAdapterClickListener {
        void deleBookMark(LawRegulationsDetailsMode mode);

        void toBookMark(LawRegulationsDetailsMode mode);
    }
}